new Vue({
    el: '#vue',
    data: {
    	deleteUrl: AJAX_URL_USER + 'api/sys/sysRole/delete/',
    	deleteBatchUrl: AJAX_URL_USER + 'api/sys/sysRole/deletes/',
    	loadUrl: AJAX_URL_USER + 'api/sys/sysRole/list'
    },
    filters: {
    },
    mounted: function () {
		load_data(this.loadUrl, this.getcolumns());
    },
    methods: {
    	batch_remove: function() {
    		batch_remove(this.deleteBatchUrl);
    	},
        getcolumns: function() {
            var that = this;
		    var c = [{
						checkbox: true
					},
					{
						field: 'id',
						title: 'id',
						align: 'center'
					},
					{
						field: 'name',
						title: '名称',
						align: 'center'
					},
					{
						field: 'createTime',
						title: '创建时间',
						formatter: function(value, row, index) {
							return new Date(value).pattern("yyyy-MM-dd HH:mm:ss");
						},
						align: 'center'
					},
					{
						field: 'state',
						title: '状态',
						align: 'center',
						formatter: function(value, row, index) {
							if(value == '1') {
								return '<span class="label label-primary">正常</span>';
							} else if(value == '2') {
								return '<span class="label label-danger">禁用</span>';
							}
						}
					},
					{
						title: '操作',
						field: 'id',
						align: 'center',
						formatter: function(value, row, index) {
							return dt_edit_button(row) + dt_detail_button(row) + dt_delete_button(that.deleteUrl+value);
						}
					}
				];
		
		    return c;
        }
    }
});
